package com.fjrz.bbxwj.popup

import android.content.Context
import android.view.Gravity
import android.view.View
import android.view.animation.Animation
import android.view.animation.TranslateAnimation
import android.widget.ImageView
import android.widget.TextView
import com.blankj.utilcode.util.ToastUtils
import com.fjrz.bbxwj.R
import com.fjrz.bbxwj.entity.VideoList
import com.fjrz.bbxwj.main.video.adapter.DiscussGroupAdapter
import kotlinx.android.synthetic.main.popup_video_share.view.*
import razerdp.basepopup.BasePopupWindow


class VideoSharePopup(
    context: Context, val onClick: (view: View, videoList: VideoList?) -> Unit
) : BasePopupWindow(context) {

    private var mVideoList: VideoList? = null

    init {

        setAdjustInputMethod(false)
        popupGravity = Gravity.BOTTOM
        setOverlayNavigationBar(false)
        setBackgroundColor(0)
        setAlignBackground(true)
        setBlurBackgroundEnable(true)

    }

    override fun onCreateContentView(): View {
        return createPopupById(R.layout.popup_video_share)
    }

    override fun onViewCreated(contentView: View) {
        super.onViewCreated(contentView)
        contentView.ivVideoShareClose.setOnClickListener {
            dismiss()
        }
        contentView.findViewById<ImageView>(R.id.ivVideoShareWX2).setOnClickListener {
            onClick(it, mVideoList)
        }
        contentView.ivVideoShareReport.setOnClickListener {
            onClick(it, mVideoList)
        }
        contentView.ivVideoShareShieldDynamic.setOnClickListener {
            onClick(it, mVideoList)
        }
        contentView.ivVideoShareShieldPeople.setOnClickListener {
            onClick(it, mVideoList)
        }
    }

    override fun onCreateShowAnimation(width: Int, height: Int): Animation {
        return TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, 0f,
            Animation.RELATIVE_TO_PARENT, 0f,
            Animation.RELATIVE_TO_PARENT, 1f,
            Animation.RELATIVE_TO_PARENT, 0f
        ).apply { duration = 300L }
    }

    override fun onCreateDismissAnimation(): Animation {
        return TranslateAnimation(
            Animation.RELATIVE_TO_PARENT, 0f,
            Animation.RELATIVE_TO_PARENT, 0f,
            Animation.RELATIVE_TO_PARENT, 0f,
            Animation.RELATIVE_TO_PARENT, 1f
        ).apply { duration = 300L }
    }

    fun setVideoId(videoList: VideoList): VideoSharePopup {
        mVideoList = videoList
        return this
    }

}